local sk__pindi = fk.CreateSkill {

  name = "sk__pindi",

  tags = {},

}



sk__pindi:addEffect("active", {
  name = "sk__pindi",
  anim_type = "control",
  card_num = 1,
  target_num = 1,
  prompt = "#sk__pindi",
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and not player:prohibitDiscard(Fk:getCardById(to_select)) and
        Fk:currentRoom():getCardArea(to_select) == Player.Hand
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= player and
    not table.contains(player:getTableMark("sk__pindi-phase"), to_select.id)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local mark = player:getTableMark("sk__pindi-phase")
    table.insert(mark, target.id)
    room:setPlayerMark(player, "sk__pindi-phase", mark)
    room:throwCard(effect.cards, sk__pindi.name, player)
    if player.dead or target.dead then return end
    local judge = {
      who = target,
      reason = sk__pindi.name,
      pattern = ".",
    }
    room:judge(judge)
    if judge.card.color == Card.Black then
      if player.dead or target.dead then return end
      local choice = room:askForChoice(player, { "#sk__pindi-draw::" .. target.id, "#sk__pindi-discard::" .. target.id },
        sk__pindi.name)
      if choice[13] == "r" then
        target:drawCards(3, sk__pindi.name)
      else
        room:askForDiscard(target, 3, 3, true, sk__pindi.name, false)
      end
    else
      if player.dead then return end
      if judge.card.suit == Card.Diamond then
        player:drawCards(1, sk__pindi.name)
      elseif judge.card.suit == Card.Heart then
        player:turnOver()
      end
    end
  end,
})

return sk__pindi
